package com.myway.dto.order.domain;

import java.util.HashMap;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13-8-1
 * Time: 下午4:39
 * To change this template use File | Settings | File Templates.
 */
public enum PnrCancelErrorType {
    Create("Create"),//订单生成失败后清位
    Cancel("Cancel");//PNR取消失败（如取消订单、退票等）

    private final String alias;

    private static HashMap<String, PnrCancelErrorType> map;

    static
    {
        map = new HashMap<String, PnrCancelErrorType>();
        for (PnrCancelErrorType type : PnrCancelErrorType.values()) {
            map.put(type.alias, type);
        }
    }

    PnrCancelErrorType(String alias){
        this.alias = alias;
    }

    @Override
    public String toString()
    {
        return this.alias;

    }

    public static PnrCancelErrorType valueOfAlias(String alias)
    {
        PnrCancelErrorType type = map.get(alias);

        if (type == null) {
            throw new IllegalArgumentException("Unknown action alias [" + alias + "]");
        }

        return type;
    }

    /**
     * @return the alias
     */
    public String getAlias() {
        return this.alias;
    }
}
